home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / GRAPHICS / IMGLIB95 / URUBBERB.PA_ / URUBBERB.PA
Text File  |  1996-03-31  |  8KB  |  226 lines

  1. {
  2. Written by Jan Dekkers and Kevin Adams (c) 1995, 1996. If you are a non
  3. registered client, you may use or alter this demo only for evaluation
  4. purposes.
  5.  
  6. Copyright by SkyLine Tools. All rights reserved.
  7.  
  8. Part of Imagelib VCL/DLL Library.
  9. }
  10.  
  11. unit Urubberb;
  12.  
  13. {Includes settings to compile in either 16 or 32 bit}
  14. {$I DEFILIB.INC}
  15.  
  16. interface
  17.  
  18. uses
  19. {$IFDEF DEL32}
  20.   Windows,
  21. {$ELSE}
  22.   WinTypes,
  23.   WinProcs,
  24. {$ENDIF}
  25.   DLL95V1,  {ImageLib Dll interface and misc. functions}
  26.   SysUtils,
  27.   Messages,
  28.   Classes,
  29.   Graphics,
  30.   Controls,
  31.   Forms,
  32.   Dialogs,
  33.   TMultiP,  {PMultiImage VCL component}
  34.   StdCtrls,
  35.   IToolB,   {PMultiImage Toolbar VCL component}
  36.   Preview;
  37.  
  38.  
  39. type
  40.   TRubberbandForm = class(TForm)
  41.     PMultiImage1: TPMultiImage;
  42.     Label1: TLabel;
  43.     MImageToolBar1: TMImageToolBar;
  44.     Button1: TButton;
  45.     RadioButton1: TRadioButton;
  46.     RadioButton2: TRadioButton;
  47.     RadioButton3: TRadioButton;
  48.     RadioButton4: TRadioButton;
  49.     RadioButton5: TRadioButton;
  50.     RadioButton6: TRadioButton;
  51.     RadioButton7: TRadioButton;
  52.     RadioButton9: TRadioButton;
  53.     RadioButton10: TRadioButton;
  54.     RadioButton12: TRadioButton;
  55.     RadioButton13: TRadioButton;
  56.     RadioButton14: TRadioButton;
  57.     RadioButton15: TRadioButton;
  58.     Label2: TLabel;
  59.     RadioButton8: TRadioButton;
  60.     RadioButton11: TRadioButton;
  61.     ThumbPreview1: TThumbPreview;
  62.     Button2: TButton;
  63.     procedure PMultiImage1MouseMove(Sender: TObject; Shift: TShiftState; X,
  64.       Y: Integer);
  65.     procedure PMultiImage1MouseUp(Sender: TObject; Button: TMouseButton;
  66.       Shift: TShiftState; X, Y: Integer);
  67.     procedure PMultiImage1MouseDown(Sender: TObject; Button: TMouseButton;
  68.       Shift: TShiftState; X, Y: Integer);
  69.     procedure Button1Click(Sender: TObject);
  70.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  71.     procedure CopyModeClick(Sender: TObject);
  72.     procedure Button2Click(Sender: TObject);
  73.     procedure FormCreate(Sender: TObject);
  74.   private
  75.     { Private declarations }
  76.   public
  77.     { Public declarations }
  78.     pointStart: TPoint;
  79.     pointEnd  : TPoint;
  80.     bLeftDown : boolean;
  81.     procedure DrawRubberband;
  82.   end;
  83.  
  84. var
  85.   RubberbandForm: TRubberbandForm;
  86.  
  87. implementation
  88.  
  89. {$R *.DFM}
  90. {------------------------------------------------------------------------}
  91. procedure TRubberbandForm.PMultiImage1MouseDown(Sender: TObject;
  92.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  93. begin
  94.   bLeftDown := false;
  95.   if button = mbLeft then begin
  96.     PMultiImage1.ResetImage;
  97.     bLeftDown := true;
  98.     pointStart.X := X;
  99.     pointStart.Y := Y;
  100.     pointEnd.X := X;
  101.     pointEnd.Y := Y;
  102.   end;
  103. end;
  104. {------------------------------------------------------------------------}
  105.  
  106. procedure TRubberbandForm.PMultiImage1MouseMove(Sender: TObject; Shift: TShiftState;
  107.   X, Y: Integer);
  108. begin
  109.   if not bLeftDown then exit;
  110.   DrawRubberband;
  111.   pointEnd.x := X;
  112.   pointEnd.y := Y;
  113.   DrawRubberband;
  114. end;
  115. {------------------------------------------------------------------------}
  116.  
  117. procedure TRubberbandForm.PMultiImage1MouseUp(Sender: TObject; Button: TMouseButton;
  118.   Shift: TShiftState; X, Y: Integer);
  119. begin
  120.   if not bLeftDown then exit;
  121.   DrawRubberband;
  122.   bLeftDown := false;
  123.   pointEnd.X := X;
  124.   pointEnd.Y := Y;
  125.   {Zoom , flip or rotate image}
  126.   PMultiImage1.TransformImage(Rect(pointStart.X, pointStart.Y, pointEnd.X, pointEnd.Y));
  127. end;
  128. {------------------------------------------------------------------------}
  129.  
  130. procedure TRubberbandForm.DrawRubberband;
  131. begin
  132.   SetROP2(PMultiImage1.Canvas.handle, R2_NOT);
  133.   PMultiImage1.Canvas.moveto(pointStart.x, pointStart.y);
  134.   PMultiImage1.Canvas.lineto(pointStart.x, pointEnd.y);
  135.   PMultiImage1.Canvas.lineto(pointEnd.x, pointEnd.y);
  136.   PMultiImage1.Canvas.lineto(pointEnd.x, pointStart.y);
  137.   PMultiImage1.Canvas.lineto(pointStart.x, pointStart.y);
  138. end;
  139. {------------------------------------------------------------------------}
  140.  
  141. procedure TRubberbandForm.Button1Click(Sender: TObject);
  142. begin
  143.     {Show or hide the toolbar}
  144.     MImageToolBar1.ShowToolbar:= not MImageToolBar1.ShowToolbar;
  145. end;
  146. {------------------------------------------------------------------------}
  147.  
  148. procedure TRubberbandForm.FormClose(Sender: TObject;
  149.   var Action: TCloseAction);
  150. begin
  151.    RubberbandForm:=Nil;
  152.    Action:=caFree;
  153. end;
  154. {------------------------------------------------------------------------}
  155.  
  156. procedure TRubberbandForm.CopyModeClick(Sender: TObject);
  157. begin
  158.  If radiobutton1.checked then
  159.    PMultiImage1.Canvas.CopyMode:=cmBlackness;
  160.  If radiobutton2.checked then
  161.    PMultiImage1.Canvas.CopyMode:=cmDstInvert;
  162.  If radiobutton3.checked then
  163.    PMultiImage1.Canvas.CopyMode:=cmMergeCopy;
  164.  If radiobutton4.checked then
  165.    PMultiImage1.Canvas.CopyMode:=cmMergePaint;
  166.  If radiobutton5.checked then
  167.    PMultiImage1.Canvas.CopyMode:=cmNotSrcCopy;
  168.  If radiobutton6.checked then
  169.    PMultiImage1.Canvas.CopyMode:=cmNotSrcErase;
  170.  If radiobutton7.checked then
  171.    PMultiImage1.Canvas.CopyMode:=cmPatCopy;
  172.  If radiobutton11.checked then
  173.    PMultiImage1.Canvas.CopyMode:=cmPatInvert;
  174.  If radiobutton8.checked then
  175.    PMultiImage1.Canvas.CopyMode:=cmPatPaint;
  176.  If radiobutton12.checked then
  177.    PMultiImage1.Canvas.CopyMode:=cmSrcAnd;
  178.  If radiobutton9.checked then
  179.    PMultiImage1.Canvas.CopyMode:=cmSrcCopy;
  180.  If radiobutton13.checked then
  181.    PMultiImage1.Canvas.CopyMode:=cmSrcErase;
  182.  If radiobutton10.checked then
  183.    PMultiImage1.Canvas.CopyMode:=cmSrcInvert;
  184.  If radiobutton14.checked then
  185.    PMultiImage1.Canvas.CopyMode:=cmSrcPaint;
  186.  If radiobutton15.checked then
  187.    PMultiImage1.Canvas.CopyMode:=cmWhiteness;
  188.  
  189.  PMultiImage1.Invalidate;
  190. end;
  191.  
  192. {------------------------------------------------------------------------}
  193.  
  194. procedure TRubberbandForm.Button2Click(Sender: TObject);
  195. begin
  196.  ThumbPreview1.PreviewsDir:=ExtractFilePath(Application.Exename);
  197.  ThumbPreview1.DataFileDir:=ExtractFilePath(Application.Exename);
  198.  If ThumbPreview1.Execute then
  199.    PMultiImage1.Imagename:=ThumbPreview1.filename;
  200. end;
  201. {------------------------------------------------------------------------}
  202.  
  203. procedure TRubberbandForm.FormCreate(Sender: TObject);
  204. begin
  205.  MImageToolBar1.PreviewsDir:=ExtractFilePath(Application.Exename);
  206. end;
  207.  
  208.  
  209. end.
  210. {cmBlackness    Turns all output black.
  211. cmDstInvert    Inverts the destination bitmap.
  212. cmMergeCopy    Combines the pattern and the source bitmap by using the Boolean AND operator.
  213. cmMergePaint    Combines the inverted source bitmap with the destination bitmap by using the Boolean OR operator.
  214. cmNotSrcCopy    Copies the inverted source bitmap to the destination.
  215. cmNotSrcErase    Inverts the result of combining the destination and source bitmaps by using the Boolean OR operator.
  216. cmPatCopy    Copies the pattern to the destination bitmap with the pattern by using the Boolean XOR operator.
  217. cmPatInvert    Combines the destination bitmap with the pattern by using the Boolean XOR operator
  218. cmPatPaint    Combines the inverted source bitmap with the pattern by using the Boolean OR operator. Combines the result of this operation with the destination bitmap by using the Boolean OR operator.
  219. cmSrcAnd    Combines pixels from the destination and source bitmaps by using the Boolean AND operator.
  220. cmSrcCopy    Copies the source bitmap to the destination bitmap.
  221. cmSrcErase    Inverts the destination bitmap and combines the result with the source bitmap by using the Boolean AND operator.
  222. cmSrcInvert    Combines pixels from the destination and source bitmaps by using the Boolean XOR operator.
  223. cmSrcPaint    Combines pixels from the destination and source bitmaps by using the Boolean OR operator.
  224. cmWhiteness    Turns all output white.}
  225.  
  226.